﻿@page "/Po/BuyReturnDetail/Create"
@using nERP.ViewModel.Po.BuyReturnDetailVMs
@using System.ComponentModel.DataAnnotations
@inherits BasePage

<div>
    <ValidateForm @ref="vform" Model="@Model" OnValidSubmit="@Submit">
        <Row ItemsPerRow="ItemsPerRow.Three" RowType="RowType.Normal">
            <BootstrapInput @bind-Value="@Model.Entity.Seq" />
            <Select @bind-Value="@Model.Entity.BuyReturnId" Items="AllBuyReturns" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" Id="g387b90b2190b479aac5464937bc7f498" />
            <BootstrapInput @bind-Value="@Model.Entity.BuyReturnDetailCode" />
            <Select @bind-Value="@Model.Entity.BuyInWarehouseDetailId" Items="AllBuyInWarehouseDetails" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" Id="gb91bb86a262b40dc9c1bca1c9bcc677a" />
            <Select @bind-Value="@Model.Entity.BuyId" Items="AllBuys" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" Id="g68a74d4f2e7844ec916f826cf69ea370" />
            <Select @bind-Value="@Model.Entity.BuyDatailId" Items="AllBuyDatails" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" Id="g64df2afb26fd41df8c85029f8d050e15" />
            <Select @bind-Value="@Model.Entity.GoodsId" Items="AllGoodss" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" Id="g472dc2b5ce5947df9341766d7dc38857" />
            <BootstrapInput @bind-Value="@Model.Entity.GoodsName" />
            <BootstrapInput @bind-Value="@Model.Entity.GoodsSpec" />
            <BootstrapInput @bind-Value="@Model.Entity.GoodsUnit" />
            <BootstrapInput @bind-Value="@Model.Entity.ReturnNumber" />
            <BootstrapInput @bind-Value="@Model.Entity.UnitPrice" />
            <BootstrapInput @bind-Value="@Model.Entity.TotalPrice" />
            <BootstrapInput @bind-Value="@Model.Entity.DiscountPrice" />
            <BootstrapInput @bind-Value="@Model.Entity.TaxRate" />
            <BootstrapInput @bind-Value="@Model.Entity.TaxUnitPrice" />
            <BootstrapInput @bind-Value="@Model.Entity.TaxPrice" />
            <BootstrapInput @bind-Value="@Model.Entity.TotalTaxPrice" />
            <BootstrapInput @bind-Value="@Model.Entity.Remark" />
        </Row>

        <div class="modal-footer table-modal-footer">
            <Button ButtonType="ButtonType.Submit" IsAsync="true" Text="@WtmBlazor.Localizer["Sys.Submit"]" />
            <Button OnClick="OnClose" Text="@WtmBlazor.Localizer["Sys.Close"]" />
        </div>

    </ValidateForm>

</div>



@code {
    [Parameter]
    public string id { get; set; }
    [Parameter]
    public string[] ids { get; set; }
    private BuyReturnDetailVM Model = new BuyReturnDetailVM();
    private ValidateForm vform { get; set; }
    private async Task Submit(EditContext context)
    {


        await PostsForm(vform, "/api/Po/BuyReturnDetail/Create", (s) => "Sys.OprationSuccess");
    }
    public void OnClose()
    {
        CloseDialog();
    }

    private List<SelectedItem> AllBuyReturns = new List<SelectedItem>();
    private List<SelectedItem> AllBuyInWarehouseDetails = new List<SelectedItem>();
    private List<SelectedItem> AllBuys = new List<SelectedItem>();
    private List<SelectedItem> AllBuyDatails = new List<SelectedItem>();
    private List<SelectedItem> AllGoodss = new List<SelectedItem>();
    protected override async Task OnInitializedAsync()
    {


        AllBuyReturns = await WtmBlazor.Api.CallItemsApi("/api/Po/BuyReturnDetail/GetBuyReturns");
        AllBuyReturns.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"], Value = "" });
        AllBuyInWarehouseDetails = await WtmBlazor.Api.CallItemsApi("/api/Po/BuyReturnDetail/GetBuyInWarehouseDetails");
        AllBuyInWarehouseDetails.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"], Value = "" });
        AllBuys = await WtmBlazor.Api.CallItemsApi("/api/Po/BuyReturnDetail/GetBuys");
        AllBuys.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"], Value = "" });
        AllBuyDatails = await WtmBlazor.Api.CallItemsApi("/api/Po/BuyReturnDetail/GetBuyDetails");
        AllBuyDatails.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"], Value = "" });
        AllGoodss = await WtmBlazor.Api.CallItemsApi("/api/Po/BuyReturnDetail/GetGoodss");
        AllGoodss.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"], Value = "" });

        await base.OnInitializedAsync();
    }
}
